<template>
  <div>
    <van-row>
      <van-col span="20">
        <van-button type="primary" block @click="errorClick">点击抛出错误</van-button>
      </van-col>
    </van-row>
    <van-row>
      <van-col span="8">
        <van-button type="info" @click="promiseerrorClick">点击抛出Promise错误</van-button>
      </van-col>
    </van-row>
    <van-button type="warning" @click="sendSuccess">ajax 成功请求</van-button>
    <van-button type="danger" @click="sendError">ajax 失败请求</van-button>
  </div>
</template>

<script>
import send from '@/util/http/btnApi';
export default {
  name: "monitorBtn",
  methods: {
    errorClick () {
      console.log('[ a.b ] >', a.b);
      // window.someVar.error = 'error';
    },
    promiseerrorClick () {
      //会被捕获
      return new Promise(function (resolve, reject) {
        window.someVar.error = 'error';
      });
      // return new Promise(function (resolve, reject) {
      //   window.someVar.error = 'error';
      // }).catch(function (error) {
      //   //TODO:如果catch 则不会发送日志信息 需要优化
      //   console.log(error);
      // });
      //会被捕获
      // return new Promise(function (resolve, reject) {
      //   reject('123');
      // });
      //不会被捕获
      // return new Promise(function (resolve, reject) {
      //   resolve('123');
      // });
    },
    sendSuccess () {
      const res = send.success()
      console.log("%c Line:49 🥐 res", "font-size:18px;color:#ffffff;background:#99CC99", res);
    },
    sendError () {
      const res = send.error()
      console.log("%c Line:53 🍞 res", "font-size:18px;color:#ffffff;background:#FF6666", res);
    }
  },
}
</script>

<style lang="scss" scoped>
</style>